// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
import axios from 'axios'
import 'bootstrap/dist/css/bootstrap.min.css'
import '../static/css/main.css'
import '../static/css/ordering-style.css'
import jqueryForm from 'jquery-form'

Vue.config.productionTip = false

axios.defaults.baseURL='http://localhost:8080';
axios.defaults.withCredentials=true;
Vue.prototype.$http=axios;
Vue.use(ElementUI);



/* eslint-disable no-new */
 let vueApp=new Vue({
  el: '#app',
  router,
  components: { App },
  template: '<App/>'
})


axios.interceptors.response.use(resp=>{
  if(resp.data.code!=200){
    if(resp.data.code==401){
      localStorage.removeItem("userInfo");
      router.push("/");
    }else{
      vueApp.$message({
        showClose: true,
        message: resp.data.message,
        type: 'error'
      });
    }
    return;
  }
  return resp;
})

